import axios from "axios";
axios.defaults.baseURL = "/api";

const instance = axios.create({
    timeout: 5000
})

    //设置请求处理
    instance.interceptors.request.use(conf =>{
        const user=sessionStorage.getItem('user')||localStorage.getItem('user')|| null || '';
        console.log("------################---<"+user.username);
        //获取保存的用户信息
        if( user) {
            conf.headers['token'] = user.token
        }
        return conf;
    },error => {
       return Promise.reject(error)
    })

export default instance
